<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
    <link rel="stylesheet" href="/Public/Admin/css/style.css"/>
    <style>
        .layui-form .layui-form-item label.layui-form-label{width:150px}
        .layui-input, .layui-textarea{width:90%}
        #upload{background:url(/Public/Admin/images/file.png) no-repeat left center;padding-left:20px;padding-bottom:20px;display: inline-block;height: 38px;line-height: 38px;}
        .layui-form-item .title{font-size: 14px;font-weight: bold;border-bottom: 2px solid #2299ee;display: block;padding-bottom: 6px}
    </style>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Flow/flowStep',array('flow_id'=>$flow_id))}">返回</a>
                    </div>
                </blockquote>

                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="power">
                        <div class="layui-form-item">
                            <label class="layui-form-label">授权范围（人员）</label>
                            <div class="layui-input-block value">
                                <div class="auto_user textarea">
                                    <span></span>
                                    <if condition="$info['users'] neq null">
                                        <foreach name="info.users" item='user'>
                                            <span style="padding-right:10px">
                                                <a>{$user|getChineseName}</a><img class="pointer delOperator" data-id="{$user}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                                <input type="hidden" name="prcs_user[]" value="{$user}">
                                                <input type="hidden" name="user_names[]" value="{$user|getChineseName}">
                                            </span> 
                                        </foreach>
                                    </if>
                                </div>
                                <a class="pointer flowCheckUser" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/add.png"/> 添加人员&nbsp;&nbsp;</a>
                                <a class="pointer clearData" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/del1.png"/> 清空</a>
                            </div>
                            <!--定义数据表中的键名-->
                            <input type="hidden" id="userField" value="prcs_user" />
                        </div>
                        
                        <div class="layui-form-item">
                            <label class="layui-form-label">授权范围（部门）</label>
                            <div class="layui-input-block value">
                                <div class="textarea depart">
                                    <span></span>
                                    <if condition="$info['depts'] neq null">
                                        <foreach name="info.depts" item='dept'>
                                            <span style="padding-right:10px">
                                                <a>{$dept|getDeptName}</a><img class="pointer delOperator" data-id="{$dept}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                                <input type="hidden" name="prcs_dept[]" value="{$dept}">
                                                <input type="hidden" name="dept_name[]" value="{$dept|getDeptName}">
                                            </span> 
                                        </foreach>
                                    </if>
                                </div>
                                <a class="pointer addDept" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/add.png"/> 添加部门&nbsp;&nbsp;</a>
                                <a class="pointer clearData" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/del1.png"/> 清空</a>
                            </div>
                            <!--定义数据表中的键名-->
                            <input type="hidden" id="deptField" value="prcs_dept" />
                        </div>
                        
                        <div class="layui-form-item">
                            <label class="layui-form-label">授权范围（角色）</label>
                            <div class="layui-input-block value">
                                <div class="textarea priv">
                                    <span></span>
                                    <if condition="$info['privs'] neq null">
                                        <foreach name="info.privs" item='prive'>
                                            <span style="padding-right:10px">
                                                <a>{$prive|getPrivName}</a><img class="pointer delOperator" data-id="{$prive}" src="/Public/Index/img/close_red.png" alt="close" width="12">
                                                <input type="hidden" name="prcs_priv[]" value="{$prive}">
                                                <input type="hidden" name="priv_name[]" value="{$prive|getPrivName}">
                                            </span> 
                                        </foreach>
                                    </if>
                                </div>
                                <a class="pointer addPriv" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/add.png"/> 添加角色&nbsp;&nbsp;</a>
                                <a class="pointer clearData" style="vertical-align: bottom;display:inline-block"><img src="/Public/Admin/images/del1.png"/> 清空</a>
                            </div>
                            <!--定义数据表中的键名-->
                            <input type="hidden" id="field" value="prcs_priv" />
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <div class="layui-input-block button">
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('flowPower')}" data-form="">保存</a>
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        </div>
                    </div>
                    <!--加前缀为了区分选人弹窗是否有主办，name="flow_id"有主办选项，此处不需要-->
                    <input type="hidden" name="pro_flow_id" value="{$flow_id}">
                    <input type="hidden" name="prcs_id" value="{$prcs_id|default=0}">
                </form>
                <!-- 完 -->
            </div>
        </div>
    </section>
</block>
<block name="script">

    <script type="text/javascript" src="/Public/Admin/js/flow.js"></script>
    <script type="text/javascript">
        $(initFlowStep());

        $(function () {
            $('input[name=prcs_id]').focus();
        })

        //检查表单
        var flag = true;
        $('input[name=prcs_id]').on('blur', function () {
            var num = parseInt($(this).val());
            if (isNaN(num) || $(this).val() == '') {
                var msg = '步骤号必填且为整数！'
                $(this).next().text(msg);
                $('.ajax-post').removeClass('btn-submit');
            } else {
                $(this).next().text('');
                $('.ajax-post').addClass('btn-submit');
            }
        })

        $('input[name="prcs_name"]').on('blur', function () {
            if ($('input[name="prcs_name"]').val() == '') {
                var msg = '请填写步骤名称！'
                $('input[name="prcs_name"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
        })

        $('.ajax-post').on('click', function () {
            var flag = true;
            if ($('input[name="prcs_name"]').val() == '') {
                var msg = '请填写步骤名称！'
                $('input[name="prcs_name"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }

            if (flag == false) {
                $(this).removeClass('btn-submit');
            } else {
                $(this).addClass('btn-submit');
            }
        })


    </script>    
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
</block>
